package com.example.authority.service.impl;

import com.example.authority.domain.model.LoginUser;
import com.example.authority.domain.User;
import com.example.authority.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

@Service
public class UserDetailsServiceImpl implements UserDetailsService {

    @Autowired
    private UserService userService;



    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        LoginUser user = new LoginUser();
        User userByUserName = userService.getUserByUserName(username);

        user.setUser(userByUserName);
        return user;
    }
}
